//
//  UIBarButtonItem+extension.swift
//  SwiftWeibo
//
//  Created by 牟松 on 16/8/2.
//  Copyright © 2016年 DoNews. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    convenience init(MS_BarButtonItem title: String,
                     titleColor: UIColor = #colorLiteral(red: 0.431372549, green: 0.431372549, blue: 0.431372549, alpha: 1),
                     selectedTitleColor: UIColor = #colorLiteral(red: 0.9935921014, green: 0.5512711804, blue: 0.1416095039, alpha: 1),
                     imageName: String? = nil,
                     selectedImageName: String? = nil,
                     backgroundImageNmae: String? = nil,
                     selectedBackgroundImageName: String? = nil,
                     fontSize: CGFloat = 16,
                     target: AnyObject?,
                     action: Selector) {
        let button : UIButton = UIButton(MS_Button: title, titleColor: titleColor, imageName: imageName, selectedImageName: selectedImageName, backgroundImageNmae: backgroundImageNmae, selectedBackgroundImageName: selectedBackgroundImageName, fontSize: fontSize)
        button.addTarget(target, action: action, for: .touchUpInside)
        
        button.sizeToFit()
        
        self.init(customView: button)
        
    }
}
